package com.panshi.servers.impl;

import com.panshi.mapper.ArticleNoMapper;
import com.panshi.pojo.ArticleNoVO;
import com.panshi.api.util.PageSizeVO;
import com.panshi.servers.ArticleNoServers;
import io.swagger.annotations.ApiModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author XiaoWangYa
 * @version 1.0
 * @date 2020/8/4 0004 下午 9:00
 */
@Slf4j
@Service
@ApiModel("文章未审核Servers层")
public class ArticleNoServersImpl implements ArticleNoServers {

    @Autowired
    private ArticleNoMapper yb_articleNoMapper;


    @Override   // 增加文章未审核信息
    @CacheEvict(value = "articleNO", allEntries = true) // 清空缓存
    public void addArticleNoInfo(ArticleNoVO yb_ArticleNo_VO) {
        yb_articleNoMapper.addArticleNoInfo(yb_ArticleNo_VO);
    }

    @Override   // 伪删除文章未审核信息
    @CacheEvict(value = "articleNO", allEntries = true) // 清空缓存
    public void deleteArticleNoInfo(int id) {
        yb_articleNoMapper.deleteArticleNoInfo(id);
    }

    @Override   // 删除文章未审核信息
    @CacheEvict(value = "articleNO", allEntries = true) // 清空缓存
    public void delArticleNoInfo(int id) {
        yb_articleNoMapper.delArctickeNoInfo(id);
    }

    @Override   // 查询指定用户文章未审核信息
    @Cacheable(value = "articleNO", key = "#root.methodName+#p0.startIndex") // 将数据存入缓存
    public List<ArticleNoVO> queryAssignUserArticleNoInfo(PageSizeVO yb_PageSize_VO) {
        log.info(" 查询数据库 --> 查询指定用户文章未审核信息 ");
        return yb_articleNoMapper.queryAssignUserArticleNoInfo(yb_PageSize_VO);
    }

    @Override   // 查询指定文章未审核信息
    @Cacheable(value = "articleNO", key = "#root.methodName+#id") // 将数据存入缓存
    public ArticleNoVO queryAssignArticleNoInfo(int id) {
        log.info(" 查询数据库 --> 查询指定文章未审核信息 ");
        return yb_articleNoMapper.queryAssignArticleNoInfo(id);
    }

    @Override   // 查询所有未审核文章
    @Cacheable(value = "articleNO", key = "#root.methodName+#p0.startIndex") // 将数据存入缓存
    public List<ArticleNoVO> queryArticleNoAll(PageSizeVO yb_PageSize_VO) {
        log.info(" 查询数据库 --> 查询所有未审核文章 ");
        return yb_articleNoMapper.queryArticleNoAll(yb_PageSize_VO);
    }

    @Override   // 查询未审核总数据量
    @CacheEvict(value = "articleNO", allEntries = true) // 清空缓存
    public int queryArticleNoCount() {
        return yb_articleNoMapper.queryArticleNoCount();
    }

    @Override   // 修改文章未审核信息
    @CacheEvict(value = "articleNO", allEntries = true) // 清空缓存
    public void updateAssignArticleNoInfo(ArticleNoVO yb_ArticleNo_VO) {
        log.info(" 修改文章未审核信息 --> " + yb_ArticleNo_VO);
        yb_articleNoMapper.updateAssignArticleNoInfo(yb_ArticleNo_VO);
    }
}
